package com.pet.config;

import com.pet.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 本来用来演示: 配置登录的拦截器
 *
 * @author success
 * @date 2025/3/4 15:22:09
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")//拦截一切路径
                .excludePathPatterns("/views/**","/imgs/**","/plugins/**","/css/**","/js/**")//排除一些路径 - 静态资源
                .excludePathPatterns("/user/**");//排除后端的路径
    }
}
